﻿@using Microsoft.AspNetCore.Http
@model SystemInfoModel

@inject IHttpContextAccessor httpContextAccessor;

@{
    //page title
    ViewBag.Title = Loc["Admin.System.SystemInfo"];
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption level-caption">
                    <i class="fa fa-tasks"></i>
                    @Loc["Admin.System.SystemInfo"]
                </div>
                <vc:admin-widget widget-zone="system_info_buttons" additional-data="null"/>
            </div>
            <div class="x_content form">
                <vc:admin-widget widget-zone="system_info_top" additional-data="null"/>
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div class="form-horizontal">
                                <div class="form-body">
                                    <div class="form-group">
                                        <admin-label asp-for="GrandVersion"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.GrandVersion</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="GitBranch"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.GitBranch</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="GitCommit"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.GitCommit</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="OperatingSystem"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.OperatingSystem</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="MachineName"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.MachineName</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="AspNetInfo"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.AspNetInfo</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="WebRootPath"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.WebRootPath</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="ContentRootPath"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.ContentRootPath</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="EnvironmentName"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.EnvironmentName</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="ServerTimeZone"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.ServerTimeZone</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="ServerLocalTime"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.ServerLocalTime.ToString("F")</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="ApplicationTime"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.ApplicationTime.ToString("F")</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="UtcTime"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@Model.UtcTime.ToString("F")</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="RequestScheme"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@httpContextAccessor.HttpContext.Request.Scheme</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="IsHttps"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">@httpContextAccessor.HttpContext.Request.IsHttps</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="ServerVariables"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">
                                                <a id="serverVariablesShowHide" href="javascript:toggleLoadedServerVariables();">@Loc["Admin.Common.Show"]</a>
                                            </label>
                                            <div id="pnlServerVariables" style="display:none">
                                                @foreach (var serverVariable in Model.ServerVariables)
                                                {
                                                    @serverVariable.Name<text>:</text>
                                                    @serverVariable.Value
                                                    <br/>
                                                }
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <admin-label asp-for="LoadedAssemblies"/>
                                        <div class="col-md-9 col-sm-9">
                                            <label class="control-label">
                                                <a id="loadedAssembliesShowHide" href="javascript:toggleLoadedAssemblies();">@Loc["Admin.Common.Show"]</a>
                                            </label>
                                            <div id="pnlLoadedAssemblies" style="display:none">
                                                @foreach (var assembly in Model.LoadedAssemblies)
                                                {
                                                    @assembly.FullName
                                                    if (!string.IsNullOrEmpty(assembly.Location))
                                                    {
                                                        <br/>
                                                        <em>@assembly.Location</em>
                                                    }

                                                    <br/>
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <vc:admin-widget widget-zone="system_info_bottom" additional-data="null"/>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption level-caption">
                    <i class="fa fa-tasks"></i>
                    @Loc["Admin.System.Warnings"]
                </div>
                <vc:admin-widget widget-zone="warnings_buttons" additional-data="null"/>
            </div>
            <vc:admin-widget widget-zone="warnings_top" additional-data="null"/>
            <div class="form-horizontal">
                <div class="form-body">
                    <div class="x_content">
                        <div class="form-horizontal">
                            @foreach (var warning in Model.SystemWarnings)
                            {
                                switch (warning.Level)
                                {
                                    case SystemInfoModel.SystemWarningModel.SystemWarningLevel.Pass:
                                    {
                                        <div class="form-group">
                                            <div class="offset-md-2 col-md-10 col-sm-10">
                                                <label class="control-label">
                                                    @warning.Text
                                                </label>
                                            </div>
                                        </div>
                                    }
                                        break;
                                    case SystemInfoModel.SystemWarningModel.SystemWarningLevel.Warning:
                                    {
                                        <div class="form-group">
                                            <div class="offset-md-2 col-md-10 col-sm-10">
                                                <label class="control-label">
                                                    @warning.Text
                                                </label>
                                            </div>
                                        </div>
                                    }
                                        break;
                                    case SystemInfoModel.SystemWarningModel.SystemWarningLevel.Fail:
                                    {
                                        <div class="form-group">
                                            <div class="offset-md-2 col-md-10 col-sm-10">
                                                <label class="control-label">
                                                    @warning.Text
                                                </label>
                                            </div>
                                        </div>
                                    }
                                        break;
                                }
                            }
                            <vc:admin-widget widget-zone="warnings_bottom" additional-data="null"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    function toggleLoadedAssemblies() {
        $('#pnlLoadedAssemblies').toggle();
        if ($('#pnlLoadedAssemblies').css('display') == 'none') {
            $('#loadedAssembliesShowHide').html('@Loc["Admin.Common.Show"]');
        }
        else {
            $('#loadedAssembliesShowHide').html('@Loc["Admin.Common.Hide"]');
        }
    }

    function toggleLoadedServerVariables() {
        $('#pnlServerVariables').toggle();
        if ($('#pnlServerVariables').css('display') == 'none') {
            $('#serverVariablesShowHide').html('@Loc["Admin.Common.Show"]');
        }
        else {
            $('#serverVariablesShowHide').html('@Loc["Admin.Common.Hide"]');
        }
    }
</script>